/**
 * Created by guomin on 2017/5/26.
 */
var jsonWrite = require('../conf/response');
var weixin = require('../common/weixinShare');
var client=require('../conf/redis');

client.on("error",function(err){
  console.log("Error",err);
});

module.exports = {
  getSignature:function(req,res){
    weixin.getAccessToken().then(function(access_token){
      return weixin.getJsapiTicket(access_token);
    }).then(function(jsapi_ticket) {
      return weixin.getStringSha(jsapi_ticket,req.query.url);
    }).then(function(data){
      jsonWrite(res,{"status":0,"msg":"SUCCESS","result":data});
    }).catch(function(err){
      if(err) throw err;
      jsonWrite(res,{"status":201,"msg":"服务端异常"});
    });
  }
};